
local function getSlash()
    local obj=io.popen("cd")
    local path=obj:read("*all"):sub(1,-2) --path存放当前路径
    obj:close()
    if string.find(path,'\\') then
        return '\\'
    else
        return '/'
    end
end
print(">>>>>>>>>>>>>test1>>>>>>>>>>>>>>>>")
print(getSlash())

local b = {[1] = 'chaos',
[2] = 1122 ,
[3] = function ()
	print(">>>>>>>>>>>>>")
end ,
[4] = "hahaha"
}
for i,v in ipairs(b) do
	print(i,v)
end

print(os.time())
local openDaily = {       -- 每天开放时间表 ，不配默认不限制进入
	start = "09:37:00";  -- 开放时间  默认 00:00:00
	close = "24:00:00";	 -- 关闭时间  默认 24:00:00
}
print(os.date("%X") > openDaily.start)
local curTimeDaily = os.date("%X")
local start = openDaily.start or "12:30"
local close = openDaily.close or "24:"
local disString = string.format("该场景无法进入，%s到%s开放",start,close);
if close > curTimeDaily and  curTimeDaily > start then
	print(">>>>>>>>>open")
else
	print(">>>>>>>close")
	print(disString)
end

print(tostring(12))



local function binarySearch(a, v)
    local low = 1
    local high = #a
    local mid = 1
    local times = 0
    while(low <= high) do
        times = times + 1
        mid = math.floor(( low + high) / 2)
        if a[mid] < v  then
            low = mid + 1
        elseif a[mid] > v then
            high = mid - 1
        else
            break
        end
    end
    local index = math.max(low,mid)
    table.insert(a,index,v)
    return index,times
end

-- test code
local array = {}



-- print(binarySearch(array, 0))
-- print(">>>>>>>>>>>>>>>")
-- table.insert(array,1,0)
-- for i,v in ipairs(array) do
-- 	print(i,v)
-- end
local tStart = os.time()
local msgCount = 100

for _=1,msgCount do
    local randomTime = math.random(msgCount)
    binarySearch(array, randomTime)
    -- print("randomTime",randomTime)
    -- print(binarySearch(array, randomTime))
end

local tInit = os.time()
print("msg count:"..msgCount.."  time spent:"..(tInit - tStart))
-- print(binarySearch(array, 1))
-- table.insert(array,1)
-- print(binarySearch(array, 2))
-- table.insert(array,2)
-- print(binarySearch(array, 0))
-- table.insert(array,0)
-- print(binarySearch(array, 50))
-- table.insert(array,50)
-- table.insert(array,50)
-- table.insert(array,50)
-- print(binarySearch(array, 101))
-- table.insert(array,101)